﻿@{
    Layout = "";

    Html.AddCssFileParts("~/Plugins/Feed.GoogleShoppingAdvanced/Content/styles.css");  
}
@model FeedGoogleShoppingAdvancedModel
@using Nop.Plugin.Feed.GoogleShoppingAdvanced.Models;
@using Nop.Web.Framework;
@using Telerik.Web.Mvc.UI;
@using Nop.Web.Framework.UI;
@using (Html.BeginForm())
{
    @Html.Telerik().TabStrip().Name("googlebase-configure").Items(x =>
    {
        x.Add().Text(T("Plugins.Feed.GoogleShoppingAdvanced.General").Text).Content(TabGeneral().ToHtmlString()).Selected(true);
        x.Add().Text(T("Plugins.Feed.GoogleShoppingAdvanced.Override").Text).Content(TabOverride().ToHtmlString());
    })
}
@helper TabGeneral()
{
    <table class="adminContent">
        <tr>
            <td colspan="2">
                <ul>
                    <li>At least two unique product identifiers are required. So each of your product should
                        have manufacturer (brand) and MPN (manufacturer part number) specified</li>
                    <li>Specify default tax values in your Google Merchant Center account settings</li>
                    <li>Specify default shipping values in your Google Merchant Center account settings</li>
                    <li>In order to get more info about required fields look at the following article <a
                        href="http://www.google.com/support/merchants/bin/answer.py?answer=188494" target="_blank">http://www.google.com/support/merchants/bin/answer.py?answer=188494</a> </li>
                </ul>
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr />
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.ProductPictureSize):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.ProductPictureSize)
                @Html.ValidationMessageFor(model => model.ProductPictureSize)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.StoreId):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.StoreId, Model.AvailableStores)
                @Html.ValidationMessageFor(model => model.StoreId)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CurrencyId):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.CurrencyId, Model.AvailableCurrencies)
                @Html.ValidationMessageFor(model => model.CurrencyId)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.DefaultGoogleCategory):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.DefaultGoogleCategory, Model.AvailableGoogleCategories)
                @Html.ValidationMessageFor(model => model.DefaultGoogleCategory)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.IsProductIncludedOverride):
            </td>
            <td class="adminData">
                @Html.CheckBoxFor(model => model.IsProductIncludedOverride)
                @Html.ValidationMessageFor(model => model.IsProductIncludedOverride)
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr />
            </td>
        </tr>
        <tr>
            <td colspan="2" class="adminSubHeading">
            Simple Products that have a Parent Grouped Product
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.IsUseParentGroupedProductDescription):
            </td>
            <td class="adminData">
                @Html.CheckBoxFor(model => model.IsUseParentGroupedProductDescription)
                @Html.ValidationMessageFor(model => model.IsUseParentGroupedProductDescription)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.MinProductDescriptionCharLimit):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.MinProductDescriptionCharLimit)
                @Html.ValidationMessageFor(model => model.MinProductDescriptionCharLimit)
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr />
            </td>
        </tr>
        <tr>
            <td colspan="2" class="adminSubHeading">
            Delivery Options
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.IsIncludeShippingWeight):
            </td>
            <td class="adminData">
                @Html.CheckBoxFor(model => model.IsIncludeShippingWeight)
                @Html.ValidationMessageFor(model => model.IsIncludeShippingWeight)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.IsUseAdditionalShippingChargeForDelivery):
            </td>
            <td class="adminData">
                @Html.CheckBoxFor(model => model.IsUseAdditionalShippingChargeForDelivery)
                @Html.ValidationMessageFor(model => model.IsUseAdditionalShippingChargeForDelivery)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AdditionalShippingChargeCountryId):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.AdditionalShippingChargeCountryId, Model.AvailableCountries)
                @Html.ValidationMessageFor(model => model.AdditionalShippingChargeCountryId)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AdditionalShippingChargeServiceName):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.AdditionalShippingChargeServiceName)
                @Html.ValidationMessageFor(model => model.AdditionalShippingChargeServiceName)
            </td>
        </tr>

        @if (Model.GeneratedFiles.Count > 0)
        {
            <tr class="adminSeparator">
                <td colspan="2">
                    <hr />
                </td>
            </tr>
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(m => m.GeneratedFiles):
                </td>
                <td class="adminData">
                    @for (int i = 0; i <= Model.GeneratedFiles.Count - 1; i++)
                    {
                        var generatedFile = Model.GeneratedFiles[i];
                        @generatedFile.StoreName <text>-</text> <a href="@generatedFile.FileUrl" target="_blank">@generatedFile.FileUrl</a> 
                        if (i != Model.GeneratedFiles.Count - 1)
                        {
                        <br />
                        }
                    }
                </td>
            </tr>
        }
        <tr class="adminSeparator">
            <td colspan="2">
                <hr />
            </td>
        </tr>
        <tr>
            <td colspan="2" width="100%">
                <input type="submit" name="save" class="t-button" value="@T("Admin.Common.Save")" />
                <input type="submit" name="generate" class="t-button" value="@T("Plugins.Feed.GoogleShoppingAdvanced.Generate")" />
            </td>
        </tr>
        @if (!String.IsNullOrEmpty(Model.GenerateFeedResult))
        {
            <tr class="adminSeparator">
                <td colspan="2">
                    <hr />
                </td>
            </tr>
            <tr>
                <td colspan="2" width="100%">
                    <b>@Html.Raw(Model.GenerateFeedResult)</b>
                </td>
            </tr>
        }
    </table>        
}
@helper TabOverride()
{ 
    <table class="adminContent froogle">
        <tr>
            <td colspan="2">You can download the list of allowed Google product category attributes <a href="http://www.google.com/support/merchants/bin/answer.py?answer=160081"
                target="_blank">here</a>
            </td>
        </tr>
        <tr class="adminSeparator">
            <td colspan="2">
                <hr />
            </td>
        </tr>
        <tr>
            <td>
                @(Html.Telerik().Grid<FeedGoogleShoppingAdvancedModel.GoogleAdvancedProductModel>()
                    .Name("froogleproducts-grid")
                    .DataKeys(keys =>
                    {
                        keys.Add(x => x.ProductId).RouteKey("ProductId");
                    })
                    .DataBinding(dataBinding =>
                    {
                        dataBinding.Ajax()
                            .Select("GoogleProductList", "FeedGoogleShoppingAdvanced", new RouteValueDictionary() { { "Namespaces", "Nop.Plugin.Feed.GoogleShoppingAdvanced.Controllers" }, { "area", "" } })
                            .Update("GoogleProductUpdate", "FeedGoogleShoppingAdvanced", new RouteValueDictionary() { { "Namespaces", "Nop.Plugin.Feed.GoogleShoppingAdvanced.Controllers" }, { "area", "" } });
                    })
                    .Columns(columns =>
                    {
                        columns.Bound(x => x.ProductId).ReadOnly().Visible(false);
                        columns.Bound(x => x.ProductName).ReadOnly();
                        columns.Bound(x => x.GoogleCategory).Visible(false);
                        columns.Bound(x => x.Gender).Visible(false);
                        columns.Bound(x => x.AgeGroup).Visible(false);
                        columns.Bound(x => x.Color).Visible(false);
                        columns.Bound(x => x.GoogleSize).Visible(false);
                        columns.Bound(x => x.IsIncluded).ClientTemplate("<input type='checkbox' disabled='disabled' name='IsIncluded' <#=IsIncluded ? checked='checked' : ''#> />").Visible(false);
                    })
                    .ClientRowTemplate(grid => "<div class='product-info'>" +
                            "<#= ProductName #>" +
                            "</div>" +
                            "<div class='google-info'>" +
                            "<dl>" +
                            string.Format("<dt>{0}:</dt><dd><#= GoogleCategory #></dd>", T("Plugins.Feed.GoogleShoppingAdvanced.Products.GoogleCategory").Text) +
                            string.Format("<dt>{0}:</dt><dd><#= Gender #></dd>", T("Plugins.Feed.GoogleShoppingAdvanced.Products.Gender").Text) +
                            string.Format("<dt>{0}:</dt><dd><#= AgeGroup #></dd>", T("Plugins.Feed.GoogleShoppingAdvanced.Products.AgeGroup").Text) +
                            string.Format("<dt>{0}:</dt><dd><#= Color #></dd>", T("Plugins.Feed.GoogleShoppingAdvanced.Products.Color").Text) +
                            string.Format("<dt>{0}:</dt><dd><#= GoogleSize #></dd>", T("Plugins.Feed.GoogleShoppingAdvanced.Products.Size").Text) +
                            string.Format("<dt>{0}:</dt><dd><#= IsIncluded #></dd>", T("Plugins.Feed.GoogleShoppingAdvanced.Products.IsIncluded").Text) +
                            "</dl>" +
                            "</div>" +
                            "<div class='commands'>" + grid.EditButton(null) + "</div>" +
                            "</div>")
                    .Editable(editing => editing.Mode(GridEditMode.PopUp))
                    .Pageable(settings => settings.PageSize(15).Position(GridPagerPosition.Both))
                    .EnableCustomBinding(true))
            </td>
        </tr>
    </table>
}